import { findHeadCategory } from '@/api/home'
// 分类模块
export default {
  namespaced: true,
  state () {
    return {
      // 分类信息集合
      list: []
    }
  },
  // 通过mutations来修改数据
  mutations: {
    setList (state, categoryList) {
      state.list = categoryList
    }
  },
  actions: {
    getList (context) {
      findHeadCategory().then(data => {
        console.log('findHeadCategory', data)
        // 调用mutations保存state
        context.commit('setList', data.result)
      })
    }
  }
}
